package erQiao.yfl.app.service;

import erQiao.yfl.app.dao.entity.Circle;
import erQiao.yfl.app.dao.mapper.CircleMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 圈子
 */
@Service
public class CircleService {
    @Resource
    private CircleMapper circleMapper;


    public Circle selectByPrimaryKey(int id){
        return circleMapper.selectByPrimaryKey(id);
    }
    public List<Circle> selectMyCircleByUserId(int id){
        return circleMapper.selectMyCircleByUserId(id);
    }

    public int insertCircle(Circle circle) {
        return circleMapper.insert(circle);
    }

    public int updateByPrimaryKey(Circle circle){
        return circleMapper.updateByPrimaryKey(circle);
    }

    public int delCircleById(int id){
        return circleMapper.deleteByPrimaryKey(id);
    }

    public int updteUpvote(int id){
        Circle circle= circleMapper.selectByPrimaryKey(id);
        Circle _circle  =  new Circle();
        _circle.setId(id);
        _circle.setUpvotenum(circle.getUpvotenum()+1);
        return circleMapper.updateByPrimaryKey(circle);

    }



}
